import { SelectProps } from 'naive-ui';
import { reactive } from 'vue';
import { bizSuccessTextEnum, bizTypeTextEnum } from './Service';

const getBizSuccessTextOptions = () => {
  const temp: any = [];
  Object.keys(bizSuccessTextEnum).forEach(function(key: any) {
    temp.push({
      value: parseInt(key),
      label: bizSuccessTextEnum[key].text
    });
  });
  return temp.reverse();
};
const getBizTypeTextEnumOptions = () => {
  const temp: any = [];
  Object.keys(bizTypeTextEnum).forEach(function(key: any) {
    temp.push({
      value: parseInt(key),
      label: bizTypeTextEnum[key].text
    });
  });
  console.log('test-temp', temp.reverse())
  return temp.reverse();
};
/**这里写一些无需接口定义的options(例如下拉框等) */
const allOptions: Record<string, SelectProps['options']> = {
  type: getBizTypeTextEnumOptions(),
  isSuccess: getBizSuccessTextOptions()
};
const optionsMap = reactive(new Map());
for (const key in allOptions) {
  optionsMap.set(key, allOptions[key]);
}
/**异步获取选项参数的方法示例 */
async function setstreetName() {
  
}
let isLoading = false

//TODO 若项目要打成npm包，请务必在局部作用域调用
/**若项目要打成npm包，请务必在局部作用域调用 */
export const getOptionsMap = () => {
  if (!isLoading) {
    setstreetName();
    isLoading = true
  }
  return optionsMap;
};

